<template>
  <div class="chapterContend">
    <div class="container">
      <section class="chooseCarType">
        <div class="topTitleTab">
          <span>当前位置：首页 > 模拟考试 > {{ subText }} > {{type}}</span>
        </div>
        <!-- 排行榜 -->
        <section class="chapter">
          <div class="title">
              <span v-if="category==1">{{ city ? city.title : "" }}小车{{ subText }}{{type}}</span>
            <span v-if="category==2">{{ city ? city.title : "" }}货车{{ subText }}{{type}}</span>
            <span v-if="category==3">{{ city ? city.title : "" }}客车{{ subText }}{{type}}</span>
            <span v-if="category==4">{{ city ? city.title : "" }}摩托车{{ subText }}{{type}}</span>
            <span v-if="category==5">{{ city ? city.title : "" }}{{ subText }}{{type}}</span>
            <span class="tips">口碑人气排行榜，助你轻松找驾校</span>
          </div>
          <div class="list">
            <div class="exeItem" v-for="exeItem,i in exeList" :key="i">
              <div class="titleTop">
                <img :src="require(`~/assets/images/exe${i}.png`)" alt="">
                <span class="title">{{exeItem.title}}</span>
                <span class="num">（{{exeItem.count}}）题</span>
              </div>
              <div class="questionBox">
                <div class="quertionItem curp" v-for="item,j in exeItem.list" :key="j">
                 <nuxt-link :to="{name:'examination-questions', query: { sub: sub,type: type, group:group,category: category ,column:exeItem.column,columnId:item.id},}">
                    <span>{{item.title}}</span><span>（{{item.count}}）题</span>
                 </nuxt-link>
                </div>
              </div>
            </div>
          </div>
        </section>
      </section>
    </div>
  </div>
</template>
<script>
import { mapGetters, mapState } from "vuex";
import { questionSpecial } from "~/api/question";
export default {
  components: {},
  data() {
    return {};
  },
  async asyncData({ app, query, params }) {

    let {sub,category,type,categorysub,group}=query
    let data,subText;
     type=decodeURIComponent(type)
    subText=sub == 1 ? "科目一" : "科目四"
    if(category==5){
      sub=1
      if(categorysub==1){
        subText='客运'
      }else if(categorysub==2){
            subText='货运'
      }else if(categorysub==3){
            subText='危险品'
      }
      else if(categorysub==4){
            subText='教练员'
      }
       else if(categorysub==5){
            subText='出租车'
      }
    }
    if (sub && category) {
      data = await questionSpecial({ course: sub,group:group, category: category});

    }

    return {
      subText:subText,
      exeList: data,
      category: category,
      sub: sub,
      type: type,
      group:group,
    };
  },
  methods: {},
     computed: {
    ...mapState("navList", [ "city"]),
  },
};
</script>

<style scoped lang='scss'>
@import "~/assets/css/exercises.scss";
</style>